package cmd

import (
	"fmt"
	cmdutils "github.com/MzoroHaHa/dev-tools/backend/app/cmd-utils"
	"github.com/spf13/cobra"
	"os"
)

var rootCmd = &cobra.Command{
	Use:   "dev-tools",
	Short: "nothing to see here.",
	Long:  `vue3, go, gin, anything I want to learn are in here. For you, maybe useless.`,
	PersistentPreRun: func(cmd *cobra.Command, args []string) {
		cmdutils.ConfigViper(configFile, cmd.Use, cmd)
	},
}
var configFile string

func Execute() {
	rootCmd.Flags().StringVarP(&configFile, cmdutils.FlagConfigFile, "f", "", "config file path")
	if err := rootCmd.Execute(); err != nil {
		fmt.Println(err)
		os.Exit(1)
	}
}
